function Popup(elm, opts) {
  this._elm = elm;
  this._opts = opts;
  this._bg = null;
  this._pane = null;
  
  this._createElements();
}

Popup.prototype._createElements = function() {
  var _self = this;
  
  var size = DOMUtils.xDocSize();
  this._bg = document.createElement('div');
  this._bg.style.backgroundImage = (this._opts && this._opts.bg == 1) ? 'url(image/pop/bb.png)' : 'url(image/pop/bw.png)';
  this._bg.style.backgroundRepeat = 'repeat';
  this._bg.style.width = size.w + 'px';
  this._bg.style.height = size.h + 'px';
  this._bg.style.position = 'absolute';
  this._bg.style.display = 'block';
  this._bg.style.top = '0px';
  this._bg.style.left = '0px';
  document.body.appendChild(this._bg);

  this._pane = document.createElement('div');
  this._pane.style.backgroundRepeat = 'repeat';
  this._pane.style.position = 'absolute';
  this._pane.style.display = 'block';
  this._pane.style.top = (this._opts && this._opts.pos) ? this._opts.pos[1] + 'px' : '0px';
  this._pane.style.left = (this._opts && this._opts.pos) ? this._opts.pos[0] + 'px' : '0px';
  this._bg.appendChild(this._pane);

  this._pane.appendChild(this._elm);
  
  if (this._opts && this._opts.bgclose == 1) {
    this._bg.style.cursor = 'pointer';
    this._bg.onclick = function() {
      _self._close.call(_self);
    };
  }
};

Popup.prototype._close = function() {
  if (this._bg) {
    document.body.removeChild(this._bg);
    this._bg = null;
    this._pane = null;
  }
}
